#ifndef __open_vip_msg_dev_uart__
#define __open_vip_msg_dev_uart__
#pragma once

#include "openvip/message.h"

namespace ovip {

class DevMsgUART : public Device
{
    std::string name;

public:
    DevMsgUART(std::string name) : name(name), Device(name) {}
    bool IsSlave() override { return true; }
    bool Handle(Message &pmsg) override
    {
        auto msg = (MemBusMsg &)pmsg;
        if (msg.IsRead()) {
            auto rsp  = msg.AsReadRsp();
            rsp->data = 0;
            rsp->fstage = 1;
            this->manager->RespMsg(this->channel, *rsp);
            return true;
        } else if (msg.IsWrite()) {
            printf("%c", (unsigned char)msg.pdata[0]);
            auto rsp = msg.AsWriteRsp();
            this->manager->RespMsg(this->channel, *rsp);
            return true;
        } else {
            Assert(false, "message operation Not implement");
        }
    }
};

} // namespace ovip

#endif
